package test.org.offsync.util

import org.junit.runner.RunWith
import org.offsync.util._
import org.specs2._
import java.util.concurrent.CyclicBarrier

@RunWith(classOf[org.specs2.runner.JUnitRunner])
class SpecScheduledExector extends org.specs2.mutable.SpecificationWithJUnit {
  "ScheduledExector works".in {
    val barrier = new CyclicBarrier(2)
    val executor = new ScheduledExecutor
    try {
      new Thread() {
        override def run(): Unit = {
          executor.run()
          barrier.await()
        }
      }.start()
    } finally {
      executor.dispose()
      barrier.await()
    }
    1 must_== 1
  }
}
